#include<iostream>
#include<set>
using namespace std;
int main()
{
    set<int> set1;
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n+m;i++)
    {
        int num;
        cin>>num;
        set1.insert(num);
    }
    set<int>::iterator it=set1.begin();;
    for(int k=0;k<set1.size();k++,it++)
    {
        if(k==set1.size()-1)
            cout<<*it<<endl;
        	//it++;
        else
            cout<<*it<<" ";

    }
    return 0;
}
